/**
  ETFRoot project, Anyang Normal University && IMP-CAS
  \class ETFTaL2Tracker
  \brief trackers for tracking with 2 timing PLs
  \author SUN Yazhou, asia.rabbit@163.com
  \since 2022-04-25
  \date 2021-04-25 last modified
  \attention
  changelog
  <table>
  <tr>  <th>Date         <th>Author      <th>Description                   </tr>
  <tr>  <td>2021-04-25   <td>Asia Sun    <td>file created                  </tr>
  </table>

  \copyright Copyright (c) 2021 Anyang Normal U. && IMP-CAS with LGPLv3 LICENSE
*/

#include "ETFTaL2Tracker.h"
#include "ETFDetectorManager.h"
#include "ETFTimer.h"

/// dcs, t0, t1: the constituent dcs and timing detectors of the tracker
ETFTaL2Tracker::ETFTaL2Tracker(const char *name, const vector<string> &dcs,
    const char *t0, const char *t1) : ETFTaLTracker(name, dcs, t0){
  if(!strcmp(name, "")) return;

  fTimer1 = dynamic_cast<ETFTimer *>(ETFDetectorManager::Instance()->GetDetector(t1));
} // end ctor

double ETFTaL2Tracker::GetTime() const{
  return (fTimer->GetTime() + fTimer1->GetTime()) / 2.;
} // end member function GetTime

int ETFTaL2Tracker::GetTimerFiredStatus() const{
  const int sta = fTimer->GetFiredStatus();
  const int sta1 = fTimer1->GetFiredStatus();
  const int ssta = sta + sta1;
  if(8 == ssta) return 4;
  if(4 == ssta) return 5;
  return ssta;
} // end member function GetTimerFiredStatus
